<?php
$conn = mysql_connect('127.0.0.1','root','root');
mysql_query('use blog',$conn);
mysql_query('set names utf8',$conn);
$cat_id = $_GET['cat_id'];

if(empty($_POST)){
	$sql = "select catname from cat where cat_id=$cat_id";
	$rs = mysql_query($sql,$conn);
	$row = mysql_fetch_row($rs);
	//print_r($row);
	require('./view/admin/catedit.html');
}else{
	$catname = trim($_POST['catname']);

	//判断栏目名是否为空
	if($catname == ''){
		echo "栏目名不能为空";
		exit();
	}

	$sql = "update cat set catname='$catname' where cat_id=$cat_id";
	//var_dump(mysql_query($sql,$conn));
	if(mysql_query($sql,$conn)){
		echo "栏目修改成功";
	}else{
		echo "栏目修改岔纰,原因:".mysql_error();
	}
}

